/*
 * TODO: License
 */

package com.rppowell.pixie.swing.mapset;

import com.rppowell.pixie.models.Map;
import com.rppowell.pixie.models.MapSet;
import com.rppowell.pixie.models.SpriteSet;
import com.rppowell.pixie.swing.map.MapWorkArea;
import java.util.Iterator;
import javax.swing.JTabbedPane;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

/**
 *
 * @author rppowell
 */

public class MapSetTabbedPane extends JTabbedPane implements ChangeListener {

    private static final long serialVersionUID = 1L;

    public MapSetTabbedPane(SpriteSet s) {
            super();
            setTabPlacement(JTabbedPane.TOP);
            setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
            this.initializeMapSet(s.getMapSet());
            addChangeListener(this);
	}
    
    public void initializeMapSet(MapSet m) {
        removeAll();
        for (Iterator<Map> it = m.iterator(); it.hasNext();) {
            Map map = it.next();
            addTab(map.getName(), new MapWorkArea(map));
        }
    }
    
    public void stateChanged(ChangeEvent ce) {
        System.out.println(getClass().toString() + ".stateChanged - " + ce);
    }   

}
